-
Notifications
You must be signed in to change notification settings - Fork 350
[ENG-8064] Notification Refactor Phase 2 #11322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
--------- Co-authored-by: John Tordoff <Johnetordoff@users.noreply.github.com> Co-authored-by: Ostap Zherebetskyi <ozherebetskyi@exoft.net> Co-authored-by: Bohdan Odintsov <bodintsov@exoft.net> Co-authored-by: John Tordoff <>
* Fix moderator digest * Fix unit tests
…ion (#11324) * Fix issue with user confirmation/merger creating subscription * Add docstrings
* Add No Login to notification template and add to tests
…tion-refactor-p2-s * Conflicts have not been resolved in this merge since we want to track how we fixed the conflicts due to complexity * api/nodes/serializers.py * osf/models/user.py * tests/test_auth.py * tests/test_webtests.py * website/templates/node_request_institutional_access_request.html.mako
…plate-with-naming [ENG-8988] Fix/notification contrib template with naming
[ENG-8997] Turn on script tests
| def tearDown(self): | ||
| super().tearDown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed
| with capture_notifications(): | ||
| fork = node.fork_node(auth_obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not we check for captured notifications?
| message = f'Failed to send registration bulk upload outcome email due to invalid ' \ | ||
| f'upload state: [upload={upload.id}, state={upload.state.name}]' | ||
| logger.error(message) | ||
| sentry.log_message(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really not want this in sentry?
| res = app.post_json_api(url, payload, auth=user.auth) | ||
| assert contributor_added in mock_signal.signals_sent() | ||
| assert res.status_code == 201 | ||
| assert mock_send_grid.call_count == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we need to verify that emails were not sent
| username, fullname, password = 'user_inactive@osf.edu', 'Foo Bar', 'FuAsKeEr' | ||
| user = make_user(username, fullname) | ||
| user.set_password(password) | ||
| with capture_notifications() as mock_signals: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| with capture_notifications() as mock_signals: | |
| with capture_notifications(): |
| @@ -467,631 +462,6 @@ def test_wiki_url(self): | |||
| assert self._url_to_body(self.wiki.deep_url) == self._url_to_body(self.wiki.url) | |||
|
|
|||
|
|
|||
| @pytest.mark.enable_bookmark_creation | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please confirm this to be intended removal
| @contextlib.contextmanager | ||
| def run_celery_tasks(): | ||
| yield | ||
| celery_teardown_request() | ||
|
|
||
| import re, html as html_lib, difflib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move imports to the start of the file
| def _safe_user_id(u: Any) -> Optional[str]: | ||
| """Normalize user object to stable identifier.""" | ||
| if u is None: | ||
| return None | ||
| for attr in ('_id', 'id', 'guids', 'guid', 'pk'): | ||
| if hasattr(u, attr): | ||
| try: | ||
| val = getattr(u, attr) | ||
| if hasattr(val, 'first'): | ||
| g = val.first() | ||
| if g and hasattr(g, '_id'): | ||
| return g._id | ||
| if isinstance(val, (str, int)): | ||
| return str(val) | ||
| except Exception: | ||
| pass | ||
| return f'obj:{id(u)}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix variable names
| def _safe_obj_id(o: Any) -> Optional[str]: | ||
| """Normalize object to stable identifier.""" | ||
| if o is None: | ||
| return None | ||
| for attr in ('_id', 'id', 'guid', 'guids', 'pk'): | ||
| if hasattr(o, attr): | ||
| try: | ||
| val = getattr(o, attr) | ||
| if hasattr(val, 'first'): | ||
| g = val.first() | ||
| if g and hasattr(g, '_id'): | ||
| return g._id | ||
| if isinstance(val, (str, int)): | ||
| return str(val) | ||
| except Exception: | ||
| pass | ||
| return f'obj:{id(o)}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix variable names
| @@ -125,36 +82,6 @@ def add_poster_by_email(conference, message): | |||
|
|
|||
| utils.upload_attachments(user, node, message.attachments) | |||
|
|
|||
| download_url = node.web_url_for( | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these removals intended?
[ENG-8996] Fix moderator added template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several leftover questions:
General opinion on templates:
We need to look through each one, identify redundant variables in event context and remove them. Also we need to verify that all required variables are indeed passed to templates.
This review contains only several topmost templates, therefore there supposedly are many more issues than comments
| @@ -15,6 +15,7 @@ | |||
|
|
|||
| @file_updated.connect | |||
| def update_file_guid_referent(self, target, event_type, payload, user=None): | |||
| event_type = payload['action'] | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we even need event_type parameter in this case?
I guess we should remove it or at least make it optional
| context['contributors_url'] = f'{self.machineable.target.absolute_url}contributors/' | ||
| context['project_settings_url'] = f'{self.machineable.target.absolute_url}settings/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not needed, they are not present in template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This template is not used
| @@ -7,7 +7,7 @@ | |||
| </tr> | |||
| <tr> | |||
| <td style="border-collapse: collapse;"> | |||
| Hello ${fullname},<br> | |||
| Hello ${user_fullname},<br> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
during invocation, fullname is passed instead of user_fullname
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
results are not being passed during invocation
| event_context={ | ||
| 'domain': settings.DOMAIN, | ||
| 'user_fullname': user.fullname, | ||
| 'user__id': user._id, | ||
| 'src__id': src._id, | ||
| 'src_url': src.url, | ||
| 'src_title': src.title, | ||
| 'results': results, | ||
| 'url': url, | ||
| 'can_change_preferences': False, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need only src_title here
[ENG-9005] Fix/update v2 subscriptions
Purpose
TBD
Changes
TBD
QA Notes
TBD
Documentation
TBD
Side Effects
TBD
Ticket
https://openscience.atlassian.net/browse/ENG-8064